<template>
  <div>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button
          @click="handleExport"
          preIcon="ant-design:file-excel-outlined"
          :loading="exportLoading"
        >
          {{ t('导出') }}
        </a-button>
      </template>
    </BasicTable>
  </div>
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
  import { BasicTable, useTable } from '@/components/Table';
  import { getSysVisLogPage, exportSysVisLog } from '@/api/sys/sysVisLogManage';
  import { columns, searchFormSchema } from './data';
  import { useI18n } from '@/hooks/web/useI18n';

  const { t } = useI18n();
  const [registerTable] = useTable({
    title: t('列表'),
    api: getSysVisLogPage,
    columns,
    formConfig: {
      labelWidth: 120,
      schemas: searchFormSchema,
    },
    useSearchForm: true,

    bordered: true,
    showIndexColumn: false,
  });
  let exportLoading = ref<Boolean>(false);
  const handleExport = () => {
    exportLoading.value = true;
    exportSysVisLog({})
      .then(() => {
        exportLoading.value = false;
      })
      .catch(() => {
        exportLoading.value = false;
      });
  };
</script>
